<%@ page import="java.util.List" %>
<%@ page import="com.servlet.bean.User" %><%--
  Created by IntelliJ IDEA.
  User: lpy
  Date: 2023/12/27
  Time: 9:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
jsp 中
page
request  同一个请求
session  同一个浏览器
application  servletContext 同一个项目
--%>
<html>
<head>
    <title>首页</title>
</head>
<body>
<h1>首页</h1>
<hr>
<%--  输出字符串--%>
<%=request.getAttribute("user")%> <br>
<%=session.getAttribute("user")%> <br>
<%=application.getAttribute("user")%> <br>
<hr>
<%--域的大小范围 page < request < session < application
el 表达式的取值特点  从域最小的范围开始获取
--%>
${requestScope.user} <br>
${sessionScope.user} <br>
${applicationScope.user} <br>
<hr>
<%=2 + 1%>
<hr>
加法： 2+1 =${2+1}
<hr/>
减法： 2-1=${2-1}
<hr/>
乘法： 2*3=${2*3}
<hr/>
除法：3/2=${3/2}
<hr/>
取余：3%2=${3%2}
<h1>比较运算符</h1>
2>1吗？： ${2>1}
<hr/>
2<1吗？： ${2<1}
<hr/>
2>=1吗？： ${2>=1}
<hr/>
2<=1吗？： ${2<=1}
<hr/>
2==1吗？： ${2==1}
<hr/>
<h1>逻辑运算符</h1>
2>1 && 3<2 ? ${2>1 && 3<2 } ${2>1 and 3<2 }
<hr/>
2>1 || 3<2 ? ${2>1 || 3<2 } ${2>1 or 3<2 }
<hr/>
!(2>1) ? ${not (2>1)} ${!(2>1)}
<hr/>
<h1>cif 的用法</h1>
<% request.setAttribute("admin", false);%>
<c:if test="${admin}">
    <h1>管理员</h1>
</c:if>
<c:if test="${not admin}">
    <h1>非管理员</h1>
</c:if>
<h1>cchoose 的用法</h1>
<% request.setAttribute("week", 13);%>
<c:choose>
    <c:when test="${week==1}">
        <h1>星期一</h1>
    </c:when>
    <c:when test="${week==2}">
        <h1>星期二</h1>
    </c:when>
    <c:when test="${week==3}">
        <h1>星期三</h1>
    </c:when>
    <c:when test="${week==4}">
        <h1>星期四</h1>
    </c:when>
    <c:when test="${week==5}">
        <h1>星期五</h1>
    </c:when>
    <c:otherwise>
        <h1>输入内容有误</h1>
    </c:otherwise>
</c:choose>

<ul>
    <%--    items  遍历的是谁
    \       var 遍历的数据
    --%>
    <ul>
<%--
status
   index 索引  从0开始
     count 计数 从1开始

--%>
        <c:forEach items="${list}" var="item" varStatus="status">
            <li>
                    <%--                  item user--%>
                    ${status.count} - ${status.index} - ${item.username} - ${item.age}
            </li>
        </c:forEach>
    </ul>

</ul>

</body>
</html>
